package com.chrray.position.controller.app;


import com.chrray.position.auth.Authentication;
import com.chrray.position.auth.AuthenticationContext;
import com.chrray.position.domain.FdAuthEnterprise;
import com.chrray.position.domain.dto.FdAuthEnterpriseDTO;
import com.chrray.position.domain.dto.FdAuthPersonalDTO;
import com.chrray.position.enums.app.FdUserRoleEnum;
import com.chrray.position.pojo.vo.auth.WxLoginVo;
import com.chrray.position.service.auth.WxAuthService;
import com.chrray.position.util.result.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 周冠军
 *
 * @author lm
 */
@RestController
@RequestMapping("/api/app")
@Api(value = "登录/认证", tags = "deng")
@AllArgsConstructor
public class AppAuthController {
    private final WxAuthService wxAuthService;

    @ApiOperation(value = "微信登录")
    @GetMapping("/login")
    public ResponseResult<WxLoginVo> roadStatics(@RequestParam String code) {
       return wxAuthService.jscodeAuth(code);
    }

    @ApiOperation(value = "切换身份")
    @GetMapping("/changeRole")
    public ResponseResult<Authentication> changeRole(@RequestParam Integer role) {
        return wxAuthService.changeRole(role);
    }

    @ApiOperation(value = "个人实名认证OCR")
    @PostMapping("/personRealNameAuth")
    public ResponseResult<FdAuthPersonalDTO> personRealNameAuth(@RequestParam("file")MultipartFile idImg) {
        return wxAuthService.personRealNameAuth(idImg);
    }

    @ApiOperation(value = "个人实名认证提交修改")
    @PostMapping("/save-personal-auth")
    public ResponseResult<String> savePersonalAuth(@RequestBody @Validated FdAuthPersonalDTO body) {
        return wxAuthService.savePersonalAuth(body);
    }



    @ApiOperation(value = "企业实名认证OCR")
    @PostMapping("/entRealNameAuth")
    public ResponseResult<FdAuthEnterpriseDTO> entRealNameAuth(@RequestParam("file")MultipartFile idImg) {
        return wxAuthService.entRealNameAuth(idImg);
    }

    @ApiOperation(value = "企业实名认证提交修改")
    @PostMapping("/save-enterprise-auth")
    public ResponseResult<String> saveEnterpriseAuth(@RequestBody @Validated FdAuthEnterpriseDTO body) {
        return wxAuthService.saveEnterpriseAuth(body);
    }



}

